# -*- coding: utf-8 -*-
"""
Created on Thu Sep 12 16:34:18 2019

@author: Administrator
"""

# 1037 在霍格沃兹找零钱
# 思路1：直接按照进制做减法
# 思路2：转换成统一单位后再做减法

def test():
    raw = input().split(' ')
    data = []
    for ele in raw:
        temp = [] 
        ele_raw = ele.split('.')
        temp.append(int(ele_raw[0]))
        temp.append(int(ele_raw[1]))
        temp.append(int(ele_raw[2]))
        data.append(temp)
    result = []
    
    need = switch_kunt(data[0])
    pay = switch_kunt(data[1])
    
    change = pay - need
    if change >= 0:
        result = switch_galleon(change)
    else:
        result = switch_galleon(abs(change))
        result = '-' + result
    print(result)
    
def switch_kunt(data):
    total = 0
    change = [1, 17, 29]
    length = len(data)
    for i in range(length):
        total = (total * change[i]) + data[i]
    return total

def switch_galleon(kunt_amount):
    result = []
    kunt = kunt_amount % 29
    result.append(str(kunt))
    amount = kunt_amount // 29
    sickle = amount % 17
    result.append(str(sickle))
    galleon = amount // 17
    result.append(str(galleon))
    result.reverse()
    
    return '.'.join(result)

#print(switch_galleon(0))
#change = switch_kunt([14,1,28]) - switch_kunt([10, 16, 27])
#print(switch_galleon(change))
test()


# 单元测试要点
# 测试正常
# 测试错误：1.极端值情况，如0，空等 2.